VERSION 5.00
Begin VB.Form frmSelectEstimatedMonth 
   BorderStyle     =   1  'Fixed Single
   Caption         =   "Select estimated month"
   ClientHeight    =   3060
   ClientLeft      =   45
   ClientTop       =   435
   ClientWidth     =   6165
   LinkTopic       =   "Form2"
   MaxButton       =   0   'False
   MDIChild        =   -1  'True
   MinButton       =   0   'False
   ScaleHeight     =   3060
   ScaleWidth      =   6165
   Begin VB.ComboBox cboOffice 
      Height          =   315
      Left            =   4080
      TabIndex        =   6
      Top             =   360
      Width           =   1455
   End
   Begin VB.CommandButton Command1 
      Caption         =   "&OK"
      Height          =   495
      Left            =   4080
      TabIndex        =   5
      Top             =   1680
      Width           =   1095
   End
   Begin VB.ComboBox cboApplyMonth 
      Height          =   315
      Left            =   4080
      TabIndex        =   1
      Top             =   1200
      Width           =   1095
   End
   Begin VB.ComboBox cboApplyYear 
      Height          =   315
      Left            =   4080
      TabIndex        =   0
      Top             =   840
      Width           =   1095
   End
   Begin VB.Label Label2 
      AutoSize        =   -1  'True
      Caption         =   "Office"
      Height          =   195
      Left            =   3480
      TabIndex        =   7
      Top             =   360
      Width           =   420
   End
   Begin VB.Label Label1 
      Caption         =   "Please select the month of estimated expenditure what you want to edit/delete before click on the OK button."
      BeginProperty Font 
         Name            =   "MS Sans Serif"
         Size            =   9.75
         Charset         =   0
         Weight          =   700
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      ForeColor       =   &H8000000C&
      Height          =   1695
      Left            =   360
      TabIndex        =   4
      Top             =   240
      Width           =   2295
   End
   Begin VB.Label Label6 
      AutoSize        =   -1  'True
      Caption         =   "Select month"
      Height          =   195
      Left            =   3000
      TabIndex        =   3
      Top             =   1200
      Width           =   930
   End
   Begin VB.Label Label9 
      AutoSize        =   -1  'True
      Caption         =   "Select year"
      Height          =   195
      Left            =   3120
      TabIndex        =   2
      Top             =   840
      Width           =   795
   End
End
Attribute VB_Name = "frmSelectEstimatedMonth"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Private Sub cboApplyYear_Change()
Dim sql As String
Dim rs As New ADODB.Recordset
cboApplyMonth.Clear
sql = "Select distinct esapplymonth from estimated where esapplyyear ='" & cboApplyYear.Text & "' and office ='" & cboOffice.Text & "' order by esapplymonth"
Set rs = adoConnection.Execute(sql)
While Not rs.EOF
    cboApplyMonth.AddItem rs.Fields("esapplymonth").Value
       
        If Val(rs.Fields("esapplymonth").Value) = Month(Now()) Then
            cboApplyMonth.Text = rs.Fields("esapplymonth").Value
        End If
        rs.MoveNext
Wend
rs.Close
Set rs = Nothing
End Sub

Private Sub cboApplyYear_Click()
'Dim sql As String
'Dim rs As New ADODB.Recordset
'cboApplyMonth.Clear
'sql = "Select distinct esapplymonth from estimated where esapplyyear ='" & cboApplyYear.Text & "'  and office ='" & cboOffice.Text & "' order by esapplymonth"
'Set rs = adoConnection.Execute(sql)
'While Not rs.EOF
'    cboApplyMonth.AddItem rs.Fields("esapplymonth").Value
'
'        If Val(rs.Fields("esapplymonth").Value) = Month(Now()) Then
'            cboApplyMonth.Text = rs.Fields("esapplymonth").Value
'        End If
'        rs.MoveNext
'Wend
'rs.Close
'Set rs = Nothing
Call cboApplyYear_Change
End Sub

Private Sub cboOffice_Click()
Call cboApplyYear_Change
End Sub

Private Sub Command1_Click()
If Trim(cboOffice.Text) = "" Or Trim(cboApplyMonth.Text) = "" Or Trim(cboApplyYear.Text) = "" Then
    MsgBox "Please select office, month and year", vbCritical + vbOKOnly, "Accounting"
    Exit Sub
End If
Call frmEstimatedExp.filledindata(cboApplyMonth.Text, cboApplyYear.Text, cboOffice.Text)
Unload Me
End Sub

Private Sub Form_Load()
Me.Top = Screen.Height / 2 - (Me.Height / 1.5)
    Me.Left = Screen.Width / 2 - (Me.Width / 2)
' For i = 1 To 9
'        cboApplyMonth.AddItem "0" & i
'
'        If Val(i) = Month(Now()) Then
'            cboApplyMonth.ListIndex = i - 1
'        End If
'    Next
'    For i = 10 To 12
'        cboApplyMonth.AddItem i
'        If Val(i) = Month(Now()) Then
'            cboApplyMonth.ListIndex = i - 1
'        End If
'    Next
 
    
    If permit = "B" Or permit = "G" Or permit = "A" Then
        cboOffice.AddItem "GHAN"
        cboOffice.AddItem "GSGN"
        cboOffice.AddItem "GVTE"
        cboOffice.AddItem "GPNH"
    Else
         cboOffice.Text = "G" & stroffice
         cboOffice.Locked = True
    End If
       For i = 2008 To Year(Now()) + 1
        cboApplyYear.AddItem i
    Next
    cboApplyYear.Text = Year(Now())
     
End Sub
